package com.example.demo.controller;

import com.example.demo.bean.MenumDataBytitle;
import com.example.demo.bean.User;
import com.example.demo.domain.GeneralResult;
import com.example.demo.domain.GeneralResult1;
import com.example.demo.server.MenumService;
import com.example.demo.server.UserService;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 返菜单数据 各种菜单适配代码 为myAppdata  的菜单
 *
 * 动态的sql  代码
 * https://mybatis.org/mybatis-3/zh/dynamic-sql.html
 *
 * Response{protocol=http/1.1, code=404, message=, url=http://192.168.1.167:8888/selectLIneInfo?menumtype=}
 * Response{protocol=http/1.1, code=200, message=, url=http://192.168.1.167:8888/MenumDataselectall?menumtype=2}
 *
 *onFailure:242, FindFragment$1 (activity.com.myappdata.fragment)
 * com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 32 path $.data
 */

@RestController
public class MenumDataController {
    @Autowired
    private MenumService menumService;

    /***
     * 查询所有
     */
    @ApiOperation(value = "获取用户列表")
    @RequestMapping(value = "/MenumDataselectall", method = RequestMethod.GET)
    @ResponseBody
    @ApiImplicitParams({
//            @ApiImplicitParam(name = "phone", value = "手机号码", required = true, paramType = "query", dataType = "String"),
    })
//    @PostMapping("/selectall")
    public GeneralResult1 MenumDataselectAll(String menumtype) {
        GeneralResult1 g = new GeneralResult1();
        List<MenumDataBytitle> userlistall = new ArrayList<>();
        if (null != menumService.Menum(menumtype)) {
            userlistall = menumService.Menum(menumtype);
            g.setMsg("成功");
            g.setData("1111");
            g.setCode(200);
            return g;
        } else {
            return null;
        }
    }

}
